<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EditProductRelations.ascx.cs" Inherits="UCommerce.Web.UI.Catalog.EditProductRelations" %>
<%@ Register tagPrefix="commerce" tagName="ValidationSummary" src="../Controls/ValidationSummaryDisplay.ascx" %>

<commerce:ValidationSummary runat="server" />
<script type="text/javascript">
    function confirm_delete()
    {
    	return (confirm('<%# GetLocalResourceObject("ConfirmRelationDelete").ToString() %>') == true);
    }

    function openProductView(productId, parentCategoryId) {
        this.document.location.href = '<%# GetProductEditorUrl() %>?id=' + productId + '&parentCategoryId=' + parentCategoryId
    }
</script>


<div style="text-align: left;">
    <div class="propertyPane leftAligned">
        <div>
            <table style="width: 100%">
                <tr>
                    <th></th>
                    <td>
                    <asp:Repeater runat="server" DataSource="<%# RelatedProducts %>" EnableViewState="false">
                        <HeaderTemplate>
                            <table  id="sortableNodes">
                            <thead>
                                <tr>
                                    <th></th>
                                    <th><asp:Localize ID="Localize1" runat="server" meta:resourceKey="RelationTypeHeader" /></th>
                                    <th><asp:Localize ID="Localize2" runat="server" meta:resourceKey="SkuHeader" /></th>
                                    <th><asp:Localize ID="Localize3" runat="server" meta:resourceKey="NameHeader" /></th>
                                </tr>
                                </thead>
                                <tbody>
                        </HeaderTemplate>
                         <ItemTemplate>
                            <tr>
                                <td>
                                    <asp:ImageButton ID="DeleteButton" style="padding-right:5px" OnClick="DeleteButton_Clicked"  runat="server" ImageUrl="../images/ui/cross.png" CommandArgument="<%# ((ProductRelationViewObject)Container.DataItem).ProductRelationId %>" OnClientClick="return confirm_delete();" />
                                </td> 
                                <td style="width: 60px;padding-right: 15px">
                                    <%# ((ProductRelationViewObject)Container.DataItem).ProductRelationTypeName %>
                                </td>
                                <td>
                                    <asp:HiddenField runat="server" ID="ProductRelationIdHiddenField" Value="<%# ((ProductRelationViewObject)Container.DataItem).ProductRelationId %>" />
                                    <asp:Label ID="Label1" style="padding-right:10px" runat="server" Text="<%# GetSku(((ProductRelationViewObject)Container.DataItem).Product) %>" />
                                </td>
                                <td>
                                    <a onclick='openProductView(<%# ((ProductRelationViewObject)Container.DataItem).Product.ProductId %>, <%# ((ProductRelationViewObject)Container.DataItem).ParentCategoryId %>);return false;'><%# ((ProductRelationViewObject)Container.DataItem).Product.Name%></a>
                                </td>
                            </tr>
                    </ItemTemplate>
                        <FooterTemplate>
                        </tbody>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                    
                             
                    </td>
                </tr>             
            </table>
        </div>
    </div>
</div>